<div class="box_right">
	<h1>活动管理</h1>
	<p class="note note_a">
	进行中：
	<?php foreach ($result_release as $val){?>
	<?php echo date("Y/m/d",strtotime($val->start_time)).'-'.date("Y/m/d",strtotime($val->end_time)).'  "'.$val->activity_name.'"';?>
	<?php }?>
	</p>
	<div class="pro_box">
		<form id="release_form" class="layui-form" action="<?php echo base_url().'gasstation/activity/release';?>" method="post">
		<div class="layui-form-item">
		  <div class="layui-inline">
		    <div class="layui-input-inline" style="width: 200px;">
		    	<input type="text" name="start_time" class="layui-input" id="test5" placeholder="年-月-日 时:分:秒" datatype="*" nullmsg="请输入活动开始时间！">
		    </div>
		    <div class="layui-form-mid">到</div>
		    <div class="layui-input-inline" style="width: 200px;">
		    	<input type="text" name="end_time" class="layui-input" id="test6" placeholder="年-月-日 时:分:秒" datatype="*" nullmsg="请输入活动结束时间！">
		    </div>
		  </div>
		  </div>
		  
		  <div class="order_list">
			<table class="layui-table" lay-skin="line">
			  <thead>
			    <tr >
			      <th>活动列表</th>
			      <th style="width: 20%">操作</th>
			    </tr> 
			  </thead>
			  <tbody class="layui-form">
			  	<?php if (count($result)>0){
			  			foreach ($result as $val){
			  		?>
			    <tr>
			      <td>
			      	<input type="radio" name="activity_id" value="<?php echo $val->id?>" 
			      	title="<?php echo $val->activity_name?>" lay-skin="primary" <?php if ($val->check_status != '1'){?>disabled<?php }?>>
			      	<?php if ($val->check_status == '0'){?>
			      	审核中
			      	<?php }elseif ($val->check_status == '2'){?>
			      	审核拒绝
			      	<?php }?>
			      </td>
			      <td>
			      <?php if ($val->is_platform == '0'){?>
			      <a href="javascript:void(0)" onclick="delmodal('<?php echo $val->id?>')" data-toggle="modal" class="btn btn-danger btn-sm">删除</a>
			      </td>
			      <?php }?>
			    </tr>
			    <?php }
			  		}else {?>
			    <tr>
			      <td colspan="2">暂无活动</td>
			    </tr>
			    <?php }?>
			  </tbody>
			</table>
			<button class="layui-btn layui-btn-warm" style="float: right;" type="submit">发布</button>
		  </div>
		  </form>
		  <br><br>
		  <div class="order_list">
			<form id="add_form" class="layui-form" action="<?php echo base_url().'gasstation/activity/add';?>" method="post">
			<table class="layui-table" lay-skin="line">
			  <thead>
			    <tr >
			      <th>活动添加</th>
			    </tr> 
			  </thead>
			  <tbody>
			    <tr>
			      <td>
			      	<input name="activity_name" class="layui-input"  style="margin-top: 10px;" datatype="*" nullmsg="请输入活动信息！" />
			      </td>
			    </tr>
			  </tbody>
			</table>
			<button class="layui-btn layui-btn-warm" style="float: right;" type="submit">添加</button>
			</form>
		  </div> 
	</div>
</div>
<div id="delModal" class="modal fade" role="dialog" aria-hidden="true">
	<div class="modal-dialog" style="width: 300px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>提示信息</h3>
			</div>
			<div class="modal-body">
			  <p>确定要删除该活动信息吗？</p>
			</div>
			<div class="modal-footer">
			  <a id="delbtn" href="#" class="btn btn-danger">确定</a>
			  <a href="#" class="btn btn-info" data-dismiss="modal" aria-hidden="true">取消</a>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
function delmodal(id){
	$("#delbtn").attr('href','<?php echo base_url().'gasstation/activity/delete/'?>'+id);
    $('#delModal').modal('show');
}
</script>
<script>
//Demo
layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;

  //时间选择器
  laydate.render({
    elem: '#test5'
    ,type: 'datetime'
  });
    //时间选择器
  laydate.render({
    elem: '#test6'
    ,type: 'datetime'
  }); 
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script>	
<script type="text/javascript">
//验证表单
$(function(){
    $.Tipmsg.r=null;
    $("#add_form").Validform({
        tiptype:function(msg){
            layer.msg(msg);
        },
        tipSweep:true,
        ajaxPost:false
    });
    $("#release_form").Validform({
        tiptype:function(msg){
            layer.msg(msg);
        },
        tipSweep:true,
        ajaxPost:false
    });
    <?php if (isset($error)&&$error === 'error'){?>
    window.onload = function(){layer.msg('每次只能发布一个活动');};
    <?php }?>
})
</script>